package cn.xjt.Unsafe;

/**
 * @author xujiangtao
 * @create 2020-07-31-19:24
 */
public class agencyMode {
    public static void main(String[] args) {
        You xu = new You();
        Agency a = new Agency(xu);
        a.HappyMarry();
    }
}
//定义了一个接口类
interface Marry{
    void HappyMarry();
}
//实现接口类
class You implements Marry{

    @Override
    public void HappyMarry() {
        System.out.println("徐老师结婚了，很开心");
    }
}
class Agency implements Marry{
    private You target;

    public Agency(You target) {
        this.target = target;
    }
    @Override
    public void HappyMarry() {
        before();
        this.target.HappyMarry();
        after();
    }

    private void before() {
        System.out.println("很开心，马上就要结婚了");
    }

    private void after() {
        System.out.println("难过，要收尾款");
    }
}
